package com.wzw.springboot.principle.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author Wangzhiwen
 */
@Configuration
public class ThreadPoolConfiguration {

    @Bean("custom-thread-pool")
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        taskExecutor.setCorePoolSize(10);
        taskExecutor.setMaxPoolSize(60);
        taskExecutor.setThreadNamePrefix("custom-thread-pool-");
        taskExecutor.setKeepAliveSeconds(60);
        return taskExecutor;
    }

}
